<template>
	<nt-container>
		<order-form v-if="mode === 'order'" :orderInfo='orderInfo' :config="formConfig" :options="options"></order-form>
		<overtime-form v-if="mode === 'overtime'"></overtime-form>
		<refund-form v-if="mode === 'refund'"></refund-form>
		<update-form v-if="mode === 'update'"></update-form>
		<master-form v-if="mode === 'master'"></master-form>
		<invoice-form v-if="mode === 'invoice'" ref="invoice"></invoice-form>
		<praise-form v-if="mode === 'praise'"></praise-form>
		<transfer-form v-if="mode === 'transfer'"></transfer-form>
		<setfees-form v-if="mode === 'setfees'"></setfees-form>
		<recovery-form v-if="mode === 'recovery'"></recovery-form>
		<back-form v-if="mode === 'selftakeback'"></back-form>
		<notice-form v-if="mode === 'notice'"></notice-form>
		<bind-code-form v-if="mode === 'bindCode'"></bind-code-form>
		<postgg-fom v-if="mode==='postGG'"></postgg-fom>
	</nt-container>
</template>

<script>
	import {
		getOrderDetail,
		getCommonFormConfig
	} from "@/api"
	import OrderForm from "./component/order-form.vue"
	import OvertimeForm from "./component/overtime-form.vue"
	import RefundForm from "./component/refund-form.vue"
	import UpdateForm from "./component/update-form.vue"
	import MasterForm from "./component/master-form.vue"
	import InvoiceForm from "./component/invoice-form.vue"
	import PraiseForm from "./component/praise-form.vue"
	import TransferForm from "./component/transfer-form.vue"
	import SetfeesForm from "./component/setfees-form.vue"
	import RecoveryForm from "./component/recovery-form.vue"
	import BackForm from "./component/back-form.vue"
	import noticeForm from "./component/notice-form.vue"
	import postggFom from './component/postgg-form.vue'
	import bindCodeForm from './component/bind-code-form.vue'
	
	const ModeMap = new Map()
	ModeMap.set("order", "postApplyReturnIstype")
	ModeMap.set("overtime", "postApplyOvertime")
	ModeMap.set("refund", "postApplyRefund")
	ModeMap.set("update", "postApplyUpdate")
	ModeMap.set("master", "postWorkerRemarks")
	ModeMap.set("invoice", "postInvoiceEdit")
	ModeMap.set("praise", "postPraise")
	ModeMap.set("transfer", "postApplyTransfer")
	ModeMap.set("setfees", "postOrderbranchMoney")
	ModeMap.set("recovery", "postOrderbranchMoney")
	ModeMap.set("selftakeback", "postBringBack")
	ModeMap.set("notice", "postSmsnotice")
	ModeMap.set("postGG", "postGG")
	ModeMap.set("bindCode", "postMtBindCode")
	export default {
		components: {
			OrderForm,
			OvertimeForm,
			RefundForm,
			UpdateForm,
			MasterForm,
			InvoiceForm,
			PraiseForm,
			TransferForm,
			SetfeesForm,
			RecoveryForm,
			BackForm,
			noticeForm,
			postggFom,
			bindCodeForm
		},
		data() {
			return {
				// 表单模式
				mode: "order",
				orderId: "",
				options: {},
				orderInfo: {},
				formConfig: {}
			}
		},
		provide() {
			return {
				commonForm: this
			}
		},
		onLoad(options) {
			this.mode = options.mode || 'order'
			this.orderId = options.id || ""
			this.options = options || {}
			this.getDetail()
			this.getFormConfig()
		},
		methods: {
			// 订单详情
			getDetail() {
				getOrderDetail(this.orderId, ModeMap.get(this.mode)).then(res => {
					const {
						data,
						code
					} = res;
					if (code === 1) {
						this.orderInfo = data
						// console.log(data.tax_postage_price,11111111111)
						if (this.mode === 'invoice') {
							this.$refs.invoice.invoiceDetails(data.invoice)
						}
					}
				})
			},
			getFormConfig(type) {
				getCommonFormConfig(this.orderId, ModeMap.get(this.mode)).then(res => {
					const {
						code,
						data
					} = res;
					if (code !== 1) return;
					this.formConfig = data
				})
			},
		}
	}
</script>